<!-- 分类卡片 -->
<!-- 需要传递一个‘分类标识’给分类列表页面 -->
<template>
	<view class="themeItem">
		<navigator open-type="navigate"
			:url="`/pages/classlist/classlist?typeId=${item.typeId}&typeName=${item.typeName}`" class="box"
			v-if="!isMore">
			<image class="pic" :src="item.coverImg" mode="aspectFill"></image>
			<view class="mask">
				{{item.coverText}}
			</view>
			<!-- 更新时间 -->
			<!-- <view class="tab">`${updateTime.days} > 0 ? ${updateTime.days} + "天前" : ${updateTime.hours} +"h"+
				${updateTime.minutes} +"m"+"前" `</view> -->
			<view class="tab" v-if="updateTime">
				{{ updateTime}}
			</view>
		</navigator>
		<navigator open-type="switchTab" url="/pages/classify/classify" class="box more" v-if="isMore">
			<image class="pic" src="https://z-mytest.oss-cn-beijing.aliyuncs.com/creative/cg_sz08_0305.png" mode="aspectFill"></image>
			<view class="mask">
				<uni-icons type='more-filled' size='34' color="#fff"></uni-icons>
				<text class="text">更多</text>
			</view>
		</navigator>
	</view>
</template>

<script setup>
	import {
		computed
	} from 'vue';
	import {
		formatDuration
	} from "@/utils/common.js"

	const props = defineProps({
		isMore: {
			type: Boolean,
			default: false
		},
		item: {
			type: Object,
			default () {
				return {
					classifyName: '动漫',
					// 封面图片
					coverimg: '/static/images/classify1.jpg',
					updateTime: '2025-03-08 23:42:06'
				}
			}
		}

	})


	// 计算更新时间
	const updateTime = computed(() => {
		return formatDuration(props.item.updateTime);
	})
</script>

<style lang="scss" scoped>
	.themeItem {
		.box {
			height: 340rpx;
			border-radius: 10rpx;
			overflow: hidden;
			position: relative;

			.pic {
				width: 100%;
				height: 100%;
			}

			.mask {
				width: 100%;
				height: 70rpx;
				position: absolute;
				bottom: 0;
				left: 0;
				background: rgba(0, 0, 0, 0.2);
				display: flex;
				justify-content: center;
				align-items: center;
				backdrop-filter: blur(20rpx);
				font-weight: 600;
			}

			.tab {
				position: absolute;
				top: 0;
				left: 0;
				background: rgba(250, 129, 90, 0.7);
				backdrop-filter: blur(20rpx);
				color: #fff;
				font-size: 22rpx;
				padding: 6rpx 14rpx;
				// 盒子四个角的圆角
				border-radius: 0 0 20rpx 0;
				// 继续缩小字号
				transform: scale(0.8);
				transform-origin: left top;
			}
		}

		.box.more {
			.mask {
				width: 100%;
				height: 100%;
				flex-direction: column;
			}

			.text {
				font-size: 28rpx;
			}
		}
	}
</style>